home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3642 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.infi.net!usenet
  2. From: nngis@norfolk.infi.net (Greg DiGiorgio)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to search files for a string?
  5. Date: 30 Jan 1996 13:02:16 GMT
  6. Organization: Customer of InfiNet
  7. Message-ID: <4el4so$glk@nw002.infi.net>
  8. References: <4ek1qb$11m0@pulp.ucs.ualberta.ca>
  9. Reply-To: nngis@norfolk.infi.net
  10. NNTP-Posting-Host: h-geraldsgame.norfolk.infi.net
  11. Mime-Version: 1.0
  12. X-Newsreader: WinVN 0.99.3
  13.  
  14. In article <4ek1qb$11m0@pulp.ucs.ualberta.ca>, 
  15. jbukczyn@gpu.srv.ualberta.ca says...
  16. >
  17. >Anyone have good source/algorithrm/ideas of how to do this
  18. >as fast as possible?
  19. >
  20. >please reply to jbukczyn@gpu.srv.ualberta.ca
  21. >
  22. >Thanks in advance...
  23. >
  24.  
  25. You can use the std C libr function, "strstr" to do a brute force string 
  26. search or you can implement the Boyer-Moore string search method for a 
  27. 4:1 average performance increase over brute force. Boyer-moore and other 
  28. algos can be found in various text books.
  29.  
  30. There are other search algorithms as well which I am sure one of the 
  31. readers will post.
  32.  
  33. A point of fact, though... we had DB2 (IBM's industrial strength, 
  34. mainframe-based RDBMS) a couple of years ago. SQL supported searching 
  35. text fields for a substring. Since one might search a million records for 
  36. a piece of text in a column (field), you might expect that DB2 would have 
  37. implemented some super-duper string search algorithm, but it didn't. It 
  38. used "brute force".
  39.  
  40. Hope this helps some,
  41. Greg DiGiorgio
  42.  
  43.